import {View, Button, Text, Image} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, {Component} from 'react';
import * as T from '../types';
import './joinMemberModel.less';
import actions from '../actions/index';
import {connect} from 'react-redux';
import {store2Props} from '../selectors';

import {AtCurtain} from 'taro-ui';
import 'taro-ui/dist/style/components/curtain.scss';
import joinMemberImage from '@/assets/image/index/joinMember.png';
import joinMemberTitleImage from '@/assets/image/index/joinMember_title.png';

interface ComponentState {
  joinMemberModel: boolean;
}

type ITopProps = T.IProps & T.ITopProps & ComponentState;
//@ts-ignore
@connect<Partial<ITopProps>, T.ITopState>(store2Props, actions)
export default class Info extends Component<Partial<ITopProps>, T.ITopState> {
  constructor(props: ITopProps) {
    super(props);
    this.state = {};
  }

  render() {
    let {
      main: {joinMemberModel},
      actions: {action},
    } = this.props;
    return (
      // @ts-ignore
      <AtCurtain
        // @ts-ignore
        isOpened={joinMemberModel}
        onClose={() => {
          Taro.setStorageSync('joinMemberModel', true);
          action.commonChange('main.joinMemberModel', false);
        }}
      >
        <View className="joinMember">
          <Image className="joinMemberTitle" src={joinMemberTitleImage} />
          <Text className="joinMemberText">开通会员享更多优惠</Text>
          <Image className="joinMemberbg" src={joinMemberImage} />
          <View
            className="joinMemberBtn"
            onClick={() => {
              Taro.setStorageSync('joinMemberModel', true);
              action.commonChange('main.joinMemberModel', false);
              Taro.navigateTo({url: '/pages/package-A/memberOpen/index'});
            }}
          >
            开通会员
          </View>
        </View>
      </AtCurtain>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
